<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of glmerr</title>
  <meta name="keywords" content="glmerr">
  <meta name="description" content="GLMERR Evaluate error function for generalized linear model.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../menu.html">Home</a> &gt;  <a href="#">ReBEL-0.2.7</a> &gt; <a href="#">netlab</a> &gt; glmerr.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../menu.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="menu.html">Index for .\ReBEL-0.2.7\netlab&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>glmerr
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>GLMERR Evaluate error function for generalized linear model.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [e, edata, eprior, y, a, mse] = glmerr(net, x, t) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">GLMERR Evaluate error function for generalized linear model.

   Description
    E = GLMERR(NET, X, T) takes a generalized linear model data
   structure NET together with a matrix X of input vectors and a matrix
   T of target vectors, and evaluates the error function E. The choice
   of error function corresponds to the output unit activation function.
   Each row of X corresponds to one input vector and each row of T
   corresponds to one target vector.

   [E, EDATA, EPRIOR, Y, A] = GLMERR(NET, X, T) also returns the data
   and prior components of the total error.

   [E, EDATA, EPRIOR, Y, A] = GLMERR(NET, X) also returns a matrix Y
   giving the outputs of the models and a matrix A  giving the summed
   inputs to each output unit, where each row corresponds to one
   pattern.

   See also
   <a href="glm.html" class="code" title="function net = glm(nin, nout, outfunc, prior, beta)">GLM</a>, <a href="glmpak.html" class="code" title="function w = glmpak(net)">GLMPAK</a>, <a href="glmunpak.html" class="code" title="function net = glmunpak(net, w)">GLMUNPAK</a>, <a href="glmfwd.html" class="code" title="function [y, a] = glmfwd(net, x)">GLMFWD</a>, <a href="glmgrad.html" class="code" title="function [g, gdata, gprior] = glmgrad(net, x, t)">GLMGRAD</a>, <a href="glmtrain.html" class="code" title="function [net, options] = glmtrain(net, options, x, t)">GLMTRAIN</a></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="consist.html" class="code" title="function errstring = consist(model, type, inputs, outputs)">consist</a>	CONSIST Check that arguments are consistent.</li><li><a href="errbayes.html" class="code" title="function [e, edata, eprior] = errbayes(net, edata)">errbayes</a>	ERRBAYES Evaluate Bayesian error function for network.</li><li><a href="glmfwd.html" class="code" title="function [y, a] = glmfwd(net, x)">glmfwd</a>	GLMFWD	Forward propagation through generalized linear model.</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="glmtrain.html" class="code" title="function [net, options] = glmtrain(net, options, x, t)">glmtrain</a>	GLMTRAIN Specialised training of generalized linear model</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [e, edata, eprior, y, a, mse] = glmerr(net, x, t)</a>
0002 <span class="comment">%GLMERR Evaluate error function for generalized linear model.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">%   Description</span>
0005 <span class="comment">%    E = GLMERR(NET, X, T) takes a generalized linear model data</span>
0006 <span class="comment">%   structure NET together with a matrix X of input vectors and a matrix</span>
0007 <span class="comment">%   T of target vectors, and evaluates the error function E. The choice</span>
0008 <span class="comment">%   of error function corresponds to the output unit activation function.</span>
0009 <span class="comment">%   Each row of X corresponds to one input vector and each row of T</span>
0010 <span class="comment">%   corresponds to one target vector.</span>
0011 <span class="comment">%</span>
0012 <span class="comment">%   [E, EDATA, EPRIOR, Y, A] = GLMERR(NET, X, T) also returns the data</span>
0013 <span class="comment">%   and prior components of the total error.</span>
0014 <span class="comment">%</span>
0015 <span class="comment">%   [E, EDATA, EPRIOR, Y, A] = GLMERR(NET, X) also returns a matrix Y</span>
0016 <span class="comment">%   giving the outputs of the models and a matrix A  giving the summed</span>
0017 <span class="comment">%   inputs to each output unit, where each row corresponds to one</span>
0018 <span class="comment">%   pattern.</span>
0019 <span class="comment">%</span>
0020 <span class="comment">%   See also</span>
0021 <span class="comment">%   GLM, GLMPAK, GLMUNPAK, GLMFWD, GLMGRAD, GLMTRAIN</span>
0022 <span class="comment">%</span>
0023 
0024 <span class="comment">%   Copyright (c) Ian T Nabney (1996-2001)</span>
0025 
0026 <span class="comment">% Check arguments for consistency</span>
0027 errstring = <a href="consist.html" class="code" title="function errstring = consist(model, type, inputs, outputs)">consist</a>(net, <span class="string">'glm'</span>, x, t);
0028 <span class="keyword">if</span> ~isempty(errstring);
0029   error(errstring);
0030 <span class="keyword">end</span>
0031 
0032 [y, a] = <a href="glmfwd.html" class="code" title="function [y, a] = glmfwd(net, x)">glmfwd</a>(net, x);
0033 
0034 <span class="keyword">switch</span> net.outfn
0035 
0036   <span class="keyword">case</span> <span class="string">'linear'</span>     <span class="comment">% Linear outputs</span>
0037     edata = 0.5*sum(sum((y - t).^2));
0038 
0039   <span class="keyword">case</span> <span class="string">'logistic'</span>   <span class="comment">% Logistic outputs</span>
0040     edata = - sum(sum(t.*log(y) + (1 - t).*log(1 - y)));
0041 
0042   <span class="keyword">case</span> <span class="string">'softmax'</span>    <span class="comment">% Softmax outputs</span>
0043     edata = - sum(sum(t.*log(y)));
0044 
0045   <span class="keyword">otherwise</span>
0046     error([<span class="string">'Unknown activation function '</span>, net.outfn]);
0047 <span class="keyword">end</span>
0048 
0049 mse = (2*edata) / size(t,1);
0050 
0051 [e, edata, eprior] = <a href="errbayes.html" class="code" title="function [e, edata, eprior] = errbayes(net, edata)">errbayes</a>(net, edata);</pre></div>
<hr><address>Generated on Tue 26-Sep-2006 10:36:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>